<?php

/*
 * @author Ebrain Cedeno <ebraincedeno@gmail.com>
 */

class TComboBox extends TWidget{
    
    public $Options = array(array(0,'SELECCIONE'));
    public $Selected = '';
    public $Disabled = false;
    
    public function __construct($name = __CLASS__) {
        parent::__construct($name);
        $this->Width = 200;
        $this->Height = 25;
    }
    
    public function show(){
        
        if (!array_key_exists('style', $this->OptionsAditional)){
            $this->OptionsAditional['style'] = array('width:'.$this->Width.'px','height:'.$this->Height.'px');
        }
        else{
            $this->OptionsAditional['style'][] = 'width:'.$this->Width.'px';
            $this->OptionsAditional['style'][] = 'height:'.$this->Height.'px';
        }
        
        if ($this->Visible == true){
            
            $select = '<select name="'.$this->Name.'" id="'.$this->Id.'" '.$this->getOptionsAditional().' >';
            
            foreach ($this->Options as $key => $value){
                
                if ($this->Selected == $value[0]){
                    $selected = 'selected="selected"';
                }
                else{
                    $selected = '';
                }
                
                if (strtolower($value[1]) == "seleccione"){
                    $select .= '<option value="">'.$value[1].'</option>';
                }
                else{
                    $select .= '<option value="'.$value[0].'" '.$selected.'>'.$value[1].'</option>';
                }
            }
            
            $select .= '</select>';
            
            return $select;
        }
        else{
            return '';
        }
        
    }
}
?>
